﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Unity.Configuration;
using System.Configuration;

namespace WayneGameSolution
{
    public static class Unity
    {
        static public IDictionary<string,IUnityContainer> Containers
        { get; set; }

        static public IUnityContainer DefaultContainer { get { return Containers["Default"]; } }


        static Unity()
        {
            Containers = new System.Collections.Generic.Sync.SyncDictionary<string, IUnityContainer>();
            InitContainers();
        }

        private static void  InitContainers()
        {
            UnityConfigurationSection section
              = (UnityConfigurationSection)ConfigurationManager.GetSection("unity");

            var col = section.Containers ;
            var cnt = col.Count;
            for (var i = 0; i <= cnt; i++)
            {
                var uc = col[i];
                IUnityContainer container = new UnityContainer();
                uc.Configure(container);
                Containers.Add(uc.Name, container);
            }

            

          
        }

    }
}
